package com.ssww.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.ssww.entity.Banner;
import com.ssww.service.BannerService;

@Controller
@RequestMapping("/ssww")
public class BannerController implements SswwUrlController {
	@Resource
	private BannerService bannerService;
	//http://www.ssww.com:8099/ssww?method=ssww9
	@RequestMapping(params = "method=ssww9")
	public String ssww(HttpServletRequest request, ModelMap modelMap) {
//		 Banner  banner=new Banner();
//		 banner.setHfDetail("cvsker");
//		 banner.setHfLink("http://www.aicai.com");
//		 banner.setHfName("new style");
//		 banner.setHfPicUrl("dsda");
//		 bannerService.addBanner(banner);
		
		return INDEX;
	}

	@RequestMapping(params = "method=hello")
	public String hello(HttpServletRequest request, ModelMap modelMap) {
		Banner  banner=	bannerService.getBannerById(1);
		System.out.println(banner.getHfDetail());
		
		return NEWS;
	}

	@RequestMapping(params = "method=h")
	public String hello1(HttpServletRequest request, ModelMap modelMap) {
		
		bannerService.deleteBanner(1);
		return NEWS;
	}
	
	@RequestMapping(params = "method=getall")
	public String getall(HttpServletRequest request, ModelMap modelMap) {
		
	List<Banner> list=	bannerService.getBannerList();
	for (Banner banner : list) {
		System.out.println(banner.getHfDetail()+"--"+banner.getHfLink());
		
	}
		return NEWS;
	}
	
}
